#ifndef WORLD_H
#define WORLD_H

#include "gamewindow.h"
#include "gameconstants.h"
#include <vector>
#include <QMap>

class WorldObject;

using namespace std;

class World
{
private:
    static World world;

    vector<WorldObject*> objects; // the 1st object in here (at index 0) is always Monkey1, the 2nd one is Monkey2

    ModelObserver* mObs;

    WorldObject* findMonkeyAITarget();

public:

    void attachObserver(ModelObserver* mO) {
        mObs = mO;
    }

    void updateWorld();
    void setMonkeyMoveState(PlayerType pl, bool moveable, Direction dir = UP);
    void createMonkeys();
    void createCoconut(PlayerType pl);
    void createBanana();
    void doMonkeyAIMove();

    // adds a WorldObject to the world
    void addObject(WorldObject* o);

    // returns a worldobject with <id>
    WorldObject* getById(int id);

    // returns objects
    vector<WorldObject*>& getObjects() { return objects; }

    // Removes worldobject with <id> from objects
    void destroyById(int id);

    // Resets world
    void reset();

    // returns a reference to <world>
    static World& getWorld() { return world; }

    // Destroy objects
    ~World();

};

#endif // WORLD_H
